#include <bits/stdc++.h>
using namespace std;
int T,n,t[40],a[40],ans;
int count(){
    int c[40],cnt = 0;
    memset(c,0,sizeof(c));
    for(int i = 1;i <= n;i++){
        for(int j = 1;j < i;j++){
            if(t[i] == t[j] && a[i] == a[j]) c[i]++;
        }
    }
    for(int i = 1;i <= n;i++) cnt += c[i];
    return cnt;
}
void dfs(int x){
    if(x > n){
        ans = max(ans,count());
        return;
    }
    for(int i = 0;i < 2;i++){
        t[x] = i;
        dfs(x+1);
    }
}
int main(){
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    scanf("%d",&T);
    while(T--){
        scanf("%d",&n);
        memset(a,0,sizeof(a));
        for(int i = 1;i <= n;i++) scanf("%d",&a[i]);
        memset(t,0,sizeof(t));
        dfs(1);
        printf("%d\n",ans);
        ans = 0;
    }
    return 0;
}
